﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using Seeker.Business.Admin;
using System.Web.Script.Services;
using Seeker.Model.Interface;

namespace Seeker.AdminUI.Services
{
    /// <summary>
    /// AUserService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://y1y7.com/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    [System.Web.Script.Services.ScriptService]
    public class AUserService : System.Web.Services.WebService
    {
        [WebMethod]
        public string ErrorMsg()
        {
            return "迷路了吗？亲！";
        }

        /// <summary>
        /// 验证登陆
        /// </summary>
        /// <param name="uid">账号</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string LoginVerify(string uid, string pwd)
        {
            AdminUsers au = new AdminUsers();

            return au.LoginVerify(uid, pwd);

        }


        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="uid">用户ID</param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Model.AUsers GetUserInfo(int uid)
        {
            Model.AUsers user = (Model.AUsers)new AdminUsers().GetUserInfo(uid);
            return user;
        }


        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="p">当前页</param>
        /// <param name="s">页面大小</param>
        /// <param name="n">用户名/UID</param>
        /// <param name="i">状态</param>
        /// <param name="o">排序: a表示升序，否则降序</param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public List<Model.AUsers> GetUserList(int p, int s, string n, string i, string o)
        {
            bool? _i;

            try
            {
                _i = Convert.ToBoolean(i);
            }
            catch
            {
                _i = null;
            }

            return new AdminUsers().GetUserList(p, s, n, _i, o);

        }
    }
}
